package com.syyo.gulimall.order.domain.vo;

import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * @ author: wang
 * @ date: 2021/4/26 14:56
 * @ Description:
 */
public class OrderConfirmVo {

    // 收货地址
    @Getter
    @Setter
    private List<MemberAddressVo> addressVoList;

    // 选择的商品
    @Getter
    @Setter
    private List<OrderItemVo> itemVos;

    // 积分
    @Getter
    @Setter
    private Integer integration;

    // 订单总额
//    private BigDecimal total;
    // 应付总额
//    private BigDecimal payTotal;

    // 订单防重令牌
    @Getter
    @Setter
    private String  orderToke;

    @Getter
    @Setter
    private Map<Long,Boolean> stocks;

    public BigDecimal getTotal() {
        BigDecimal sum = new BigDecimal("0");
        if (itemVos != null){
            for (OrderItemVo itemVo : itemVos) {
                BigDecimal multiply = itemVo.getPrice().multiply(new BigDecimal(itemVo.getCount().toString()));
                sum = sum.add(multiply);
            }
        }
        return sum;
    }

    public BigDecimal getPayTotal() {
        return getTotal();
    }


    public Integer getCount() {

        Integer sum = 0;
        if (itemVos != null){
            for (OrderItemVo itemVo : itemVos) {
                sum+= itemVo.getCount();
            }
        }
        return sum;
    }

}
